package com.crrcdt.thread;

/**
 * @author lj on 2020/11/18.
 * @version 1.0
 */
public class JoinThreadTest implements Runnable {
   private String name;

    public JoinThreadTest(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        for (int i = 0; i <50 ; i++) {
            System.out.println(Thread.currentThread().getName()+"运行"+i);
        }
    }

    public static void main(String[] args) {
        final Thread t = new Thread(new JoinThreadTest("线程A"));
        t.start();
        for (int i = 0; i <50 ; i++) {
            if(i>10){
                try {
                    t.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("Main线程运行"+ i);
        }
    }
}
